/*
Audica Uploader - application for convenient uploading to various file hostings
Copyright (C) 2012 Makarov Andrey (Winand)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CHARSETTER_H
#define CHARSETTER_H
#include <QObject>
#include "global.h"

class Charsetter : public QObject
{
Q_OBJECT
Q_ENUMS(Charsets)
public:
    enum Charsets {
        CS_ASCII = 101,
        CS_LATIN1,
        CS_UTF8
    };
    explicit Charsetter(QObject* parent) : QObject(parent), cs_names(CS_ASCII), cs_values(CS_ASCII) {}
protected:
    Charsets cs_names;
    Charsets cs_values;
    QByteArray strConv(const QString str, Charsets cs) {
        switch(cs) {
        case CS_ASCII:
            return str.toAscii();
            break;
        case CS_LATIN1:
            return str.toLatin1();
            break;
        case CS_UTF8:
            return str.toUtf8();
        }
        return QByteArray();
    }
public slots:
    void setNamesCharset(Charsets cs) {
        if(inEnum(cs, "Charsets")) cs_names = cs;
    }
    void setValuesCharset(Charsets cs) {
        if(inEnum(cs, "Charsets")) cs_values = cs;
    }
};

#endif // CHARSETTER_H
